package sliver.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "box_taglog")
public class TagLog implements Serializable{
	
	private static final long serialVersionUID = -3269308700077117183L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id")
	private Integer id;
	
	@Column(name = "moment")
	private int moment;
	
	@Column(name = "price")
	private Double price;
	
	@Column(name = "position")
	private Integer position;
	
	@ManyToOne
	@JoinColumn(name = "tag_id")
	private Tag tag;
	
	@ManyToMany(cascade = {CascadeType.PERSIST , CascadeType.REMOVE},
			fetch = FetchType.EAGER, targetEntity = Province.class)
	@JoinTable(name = "box_rel_taglog_province",
			joinColumns = {@JoinColumn(name = "taglog_id")},
			inverseJoinColumns = {@JoinColumn(name = "province_id")})
	private Set<Province> provinces = new HashSet<Province>();
	
	public TagLog(){
		
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getMoment() {
		return moment;
	}

	public void setMoment(int moment) {
		this.moment = moment;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}
	
	public Integer getPosition() {
		return position;
	}

	public void setPosition(Integer position) {
		this.position = position;
	}

	public Tag getTag() {
		return tag;
	}

	public void setTag(Tag tag) {
		this.tag = tag;
	}

	public Set<Province> getProvinces() {
		return provinces;
	}

	public void setProvinces(Set<Province> provinces) {
		this.provinces = provinces;
	}
}